#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
struct Car{
    int d, v, a;
} a[N];
int p[N];
int n, m, L, V;
bool vis[N];
set<int> Ans[N];
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while(T--){
        for(auto w : Ans) w.clear();
        cin >> n >> m >> L >> V;
        for(int i = 1; i <= n; i++) cin >> a[i].d >> a[i].v >> a[i].a;
        for(int i = 1; i <= m; i++) cin >> p[i];
        int ans = 0;
        for(int i = 1; i <= n; i++){
            bool flag = 0;
            for(int j = 1; j <= m; j++){
                if(p[j] < a[i].d) continue;
                double v = sqrt(a[i].v * a[i].v + 2 * a[i].a * (p[j] - a[i].d));
                if(v > V){
                    Ans[i].insert(j);
                    flag = 1;
                }
            }
            if(flag) ++ans;
        }
        memset(vis, 0, sizeof vis);
        int cnt = 0;
        for(int i = 1; i <= m; i++){
            bool ok = 1;
            for(auto w : Ans){
                if(w.size() == 1 && *w.begin() == i){
                    ok = 0;
                    break;
                }
            }
            if(ok){
                for(int i = 0; i <= m; i++) Ans[i].erase(i);
                ++cnt;
            }
        }
        cout << ans << " " << cnt / 2 << "\n";
    }
    return 0;
}
